begintownscript;

variables;


int i,a,j,k,choice;

body;

beginstate 0;
set_crime_tolerance (5);
break;

beginstate 1;
break;
beginstate 2;
break;

beginstate 53;
put_boom_on_char(0,168,0);
run_animation();
break;

beginstate 15;
block_entry(1);
break;

beginstate 20;
message_dialog("You attempt to manipulate the controls, but they are far beyond your skills.","The Power core stays active.");
break;

beginstate 21;
if (get_flag(52,3) < 1){
message_dialog("Unfortunately, you aren't very popular around here, and your actions make you even less so.","(The people inside are now hostile, so things may get tougher)");
//set_town_hostile(1);
set_flag(52,3,1);}
break;

beginstate 51;

if (get_flag(52,4) > 0)
			end();		
		
		set_total_visibility(1);
		relocate_character(72,55,42);
		force_view_center(53,40);
		force_instant_terrain_redraw();
		pause(5);
		
		force_view_center(53,40);
		//text_bubble_on_char(?,"");
		text_bubble_on_char(72,"Ah, you've arrived. Come to");
		force_instant_terrain_redraw();
		pause(15);
		
		force_view_center(53,40);
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"where I can see you properly.");
		force_instant_terrain_redraw();
		pause(15);
		
		relocate_character(72,49,43);
		force_instant_terrain_redraw();
		pause(5);
		
		force_view_center(48,41);
		i = random_party_member();
		text_bubble_on_char(72,"");
		text_bubble_on_char(i,"Okay, moved. Can you see better?");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(i,"");
		text_bubble_on_char(72,"Yes, thank you.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(i,"Pleasure.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(i,"");
		text_bubble_on_char(72,"Really?");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(i,"No.");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(i,"");
		text_bubble_on_char(72,"I did not think so.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"Well, then, let's talk.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(i,"Talk?");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(i,"");
		text_bubble_on_char(72,"Yes, Talk.");
		force_instant_terrain_redraw();
		pause(10);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"I have a proposition for you.");
		force_instant_terrain_redraw();
		pause(15);
	
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"You may not accept, and I will not");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"blame you if you don't. Are you");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"willing to listen to what I have");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"to say?");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(i,"We are willing. What is your");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(i,"");
		text_bubble_on_char(i,"proposition for us?");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(i,"");
		text_bubble_on_char(72,"It is a simple one.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"My name is Rolar-Tel, I am");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"the son of the late Rentar-Ihrno.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"However, I did not share her views");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"on the subject of destroying humans and");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"their allies. Of-course, I am young,");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"so I was not alive when the Empire");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"stole the Crystal Souls from us.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"But I DO know the problems it");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"caused, for both the");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"Empire and us.");
		force_instant_terrain_redraw();
		pause(15);
		
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(i,"Okay.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(i,"");
		text_bubble_on_char(72,"I want to put all of this behind");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"us. I want this so that we can");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"look towards a better future.");
		force_instant_terrain_redraw();
		pause(15);
	
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"One generation of my clan has");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"been poisoned by the Empire's act,");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"all of those many years ago. They");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"cannot talk without saying what they");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"would do if they caught an Empire");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"citizen, or spend time awake while ");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"not thinking how to kidnap, mutilate,");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"and torture a human. This needs to stop.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"I, Rolar-Tel of the Vahnatai, propose");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"peace between our clan and the Empire,");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"Avernum, and all of their allies. Do");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"you accept?");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(i,"Though I cannot officially represent");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(i,"");
		text_bubble_on_char(i,"our people, I agree to a propositiory");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(i,"");
		text_bubble_on_char(i,"alliance.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(i,"");
		text_bubble_on_char(72,"Thank you.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"Hopefully we can begin to interact");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"with your people in a better way.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"You will find in your pocket a key");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"to the base. Near the library is the");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"passage leading to the Great Vahnatai,");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"spiral, which will take you up into the");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"Valley you have been fighting in.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"The library may have a few");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"scrolls dotted about. You may take them.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"Also, I have a small paddock of");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"Unicorns penned up. While their beauty");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"might be lost on Adventurers like you,");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"they DO have a few alchemy ingredients");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"growing with them.");
		change_spec_item(2,1);
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(i,"Thank you, I have to admit,");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(i,"");
		text_bubble_on_char(i,"I'm amazed at this.");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(i,"");
		text_bubble_on_char(72,"I am not surprised. Oh, wait,");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"I nearly forgot, the portcullises");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"will need to be opened. The control");
		force_instant_terrain_redraw();
		pause(15);
	
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"room is in the cellars, you can't");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"miss it. The key will open the door");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");
		text_bubble_on_char(72,"for you. Good Luck!");
		force_instant_terrain_redraw();
		pause(15);
		
		text_bubble_on_char(72,"");	
		force_instant_terrain_redraw();
		set_flag(52,4,1);
		set_total_visibility(0);
		
		end();
break;

beginstate 22;
	message_dialog("Amazing! Using your nefarious skills, you manage to understand this rather long-winded tome. It doesn't take you that long to learn the spell.",
	  "You now know the spell Divine Host. If your Priest skill is high enough, you can cast it!");
	j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,1,19) == 0)
				change_spell_level(a,1,19,3);
			}
			a = a + 1;
		}
break;

beginstate 23;
	message_dialog("Amazing! This spell book is highly detailed, and somewhat long-winded, and you have no trouble understanding it!",
	  "You now know the spell Arcane Blow. If your Mage skill is high enough, you can cast it!");
	j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,0,19) == 0)
				change_spell_level(a,0,19,3);
			}
			a = a + 1;
		}
break;

beginstate 24;
	message_dialog("Amazing! This spell book is highly detailed, somewhat long-winded, and you have no trouble understanding it!",
	  "You now know the spell Arcane Shield. If your Mage skill is high enough, you can cast it!");
	j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,0,18) == 0)
				change_spell_level(a,0,18,3);
			}
			a = a + 1;
		}
break;

beginstate 25;
	message_dialog("Amazing! Using your nefarious skills, you manage to understand this rather long-winded tome. It doesn't take you that long to learn the spell.",
	  "You now know the spell Divine Retribution. If your Priest skill is high enough, you can cast it!");
	j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,1,17) == 0)
				change_spell_level(a,1,17,3);
			}
			a = a + 1;
		}
break;


beginstate 26;
	message_dialog("You happen to look at the spell book lying on the table. It isn't long till you begin to read it.",
	  "Your mind floods with the multitude of spells that you are learning about. If your spell skills are high enough, you can cast them.");
	j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,1,5) < 3)
				change_spell_level(a,1,5,3);
			}
			a = a + 1;
		}
		
		j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,1,6) < 3)
				change_spell_level(a,1,6,3);
			}
			a = a + 1;
		}
		
		j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,1,7) < 3)
				change_spell_level(a,1,7,3);
			}
			a = a + 1;
		}
		
			j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,1,8) < 3)
				change_spell_level(a,1,8,3);
			}
			a = a + 1;
		}
		
		j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,1,9) < 3)
				change_spell_level(a,1,9,3);
			}
			a = a + 1;
		}
		
		j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,1,10) < 3)
				change_spell_level(a,1,10,3);
			}
			a = a + 1;
		}
		
			j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,0,5) < 3)
				change_spell_level(a,0,5,3);
			}
			a = a + 1;
		}
		
		j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,0,6) < 3)
				change_spell_level(a,0,6,3);
			}
			a = a + 1;
		}
		
		j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,0,7) < 3)
				change_spell_level(a,0,7,3);
			}
			a = a + 1;
		}
		
			j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,0,8) < 3)
				change_spell_level(a,0,8,3);
			}
			a = a + 1;
		}
		
		j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,0,9) < 3)
				change_spell_level(a,0,9,3);
			}
			a = a + 1;
		}
		
		j = get_selected_pc();
	a = 0;
	while (a < 4) {
		if (((j < 0) || (j == i)) && (char_ok(i))) {
			if (get_spell_level(a,0,10) < 3)
				change_spell_level(a,0,10,3);
			}
			a = a + 1;
		}
break;
beginstate 30;
if (get_flag(1,23) < 1){  
message_dialog("You find a secret doorway nestled between the walls. It appears to lead into a dark room. You can just make out bookshelves.","A library perhaps?");  
set_flag(1,23,1);}
break;

beginstate 34;
if (get_flag(3,24) < 1){  
message_dialog("When you enter the room you see several Vahnatai Bladesmasters. One of the speacks to you. _Avernite, Rolar-Tel has ordered us not to attack you, but to attack the skeletons._","It pauses, then continues. _If you have not spoken to Rolar-Tel yet, speak to him now. He is in the main hall._");  
set_flag(3,24,1);}
break;

beginstate 35;
	reset_dialog();
	add_dialog_str(0,"You take a look at the chair. Your instincts tell you that something will happen if you sit on it.",0);
	add_dialog_str(0,"Rolar-Tel notices you looking. _Go ahead,_ he says. _It will heal you and restore your spell energy._",0);
	add_dialog_choice(0,"Stay standing");
	add_dialog_choice(1,"Sit down, and trust Rolar-Tel.");
	choice = run_dialog(1);
	if (choice == 1)
		block_entry(1);
	if (choice == 2)
		{revive_party();
message_dialog("You sit, and a soft yellow light bathes you. You soon feel much better!","In fact, you're ready to fight some more!"); }
break;

break;